<?php

use Webman\GatewayWorker\Gateway;
use Webman\GatewayWorker\BusinessWorker;
use Webman\GatewayWorker\Register;

return [
    'gateway' => [
        'handler'     => Gateway::class,
        'listen'      => 'websocket://'.getenv('SOCKET_ADDR'),
        'count'       => cpu_count(),
        'constructor' => ['config' => [
            'lanIp'           => getenv('HOST'),
            'startPort'       => getenv('GATEWAY_START_PORT'),
            'pingInterval'    => 55,
            'pingNotResponseLimit'=>1,
            'pingData'        => '{"type":"ping"}',
            'registerAddress' => getenv('BUSSINESS_REG_ADDR'),
            'onConnect'       => function(){},
        ]]
    ],
    'business' => [
        'handler'     => BusinessWorker::class,
        'count'       => cpu_count()*2,
        'constructor' => ['config' => [
            'eventHandler'    => plugin\webman\gateway\Events::class,
            'name'            => 'ChatBusinessWorker',
            'registerAddress' => getenv('BUSSINESS_REG_ADDR'),
        ]]
    ],
    'register' => [
        'handler'     => Register::class,
        'listen'      => 'text://'.getenv('BUSSINESS_REG_ADDR'),
        'count'       => 1, // Must be 1
        'constructor' => []
    ],
];